package com.p2l.letterblocks;

import android.app.Dialog;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

public class DialogDifficulty extends Dialog {
	private DialogDifficulty dialog;
	private TextView easy, normal, hard;
	private ActivityLevel context;
	
	private int levelId, userId;
	
	private View.OnClickListener listener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			int difficulty = (Integer) v.getTag();
			Intent intent = new Intent(context, GamePersistor.class);
			intent.putExtra("userId", userId);
			intent.putExtra("levelId", levelId);
			intent.putExtra("difficulty", difficulty);
			intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
			context.startActivityForResult(intent, 1);
			dialog.dismiss();
		}
	};
	
	public DialogDifficulty(ActivityLevel context, int levelId, int userId) {
		super(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
		setContentView(R.layout.difficulty);
		
		this.dialog = this;
		this.context = context;
		this.levelId = levelId;
		this.userId	= userId;
		
		easy = (TextView) findViewById(R.id.btnEasy);
		easy.setTag(LevelLoader.EASY);
		easy.setOnClickListener(listener);
		
		normal = (TextView) findViewById(R.id.btnNormal);
		normal.setTag(LevelLoader.NORMAL);
		normal.setOnClickListener(listener);
		
		hard = (TextView) findViewById(R.id.btnHard);
		hard.setTag(LevelLoader.HARD);
		hard.setOnClickListener(listener);
	}
}